# -*- coding: utf-8 -*-
# @Time : 2021/9/17 20:03
# @Author : 伟哥
# @Email : xw@gmail.com
# @File : MRYX_WD_006.py.py
# @Project : mryx_test
'''客服与帮助，输入"蒂芬规划局"'''
from time import sleep
from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy as By


desired_capabilities={
    "platformName":"Android",
    "deviceName":"127.0.0.1:62001",
    "platformVersion":"7.1.2",
    "appPackage": "cn.missfresh.application",
    "appActivity":"cn.missfresh.module.main.view.MainActivity",
    "noReset":"True"
}
driver=webdriver.Remote("http://localhost:4723/wd/hub",desired_capabilities)
driver.implicitly_wait(60)
try:
    my_locator=(By.XPATH,'//android.widget.TextView[@resource-id=\"cn.missfresh.application:id/mineTab\"]')
    customer_servicea_locator = (By.XPATH, '//android.widget.ImageView[@content-desc=\"客服和帮助\"]')
    online_locator=(By.ID,"cn.missfresh.application:id/service_btn_img_bg")
    enter_locator=(By.ID,'cn.missfresh.application:id/sobot_et_sendmessage')
    assertion_locator=(By.XPATH,'//android.widget.TextView[@text=\"您好，优优暂时回答不上来您的问题，还在努力学习中哦～输入“人工”，马上为您联系人工客服。\"]')

    # 点击我的
    sleep(5)
    driver.find_element(*my_locator).click()
    #点击客服与帮助
    sleep(1)
    driver.find_element(*customer_servicea_locator).click()
    #点击在线客服
    sleep(1)
    driver.find_element(*online_locator).click()
    #点击疫情配送问题
    sleep(1)
    enter_element=driver.find_element(*enter_locator)
    enter_element.click()
    enter_element.send_keys("蒂芬规划局")
    #断言
    sleep(1)
    assertion=driver.find_element(*assertion_locator)
    print(assertion.text)
except Exception:
    raise
finally:
    sleep(5)
    driver.quit()